""" 滑动时间窗
    逻辑一直写不对 """
def lengthOfLongestSubstring(s: str) -> int:
    ans = 0 
    n = len(s)
    start, end= 0,0
    hashmap = set()
    while end < n:
        while s[end] in hashmap:
            hashmap.remove(s[start])
            start += 1
        hashmap.add(s[end])
        ans= max(ans, end-start+1)
        end += 1
        

    return ans

print(lengthOfLongestSubstring("pwwkew"))